package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.RoomBean;
import com.project.service.IRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("room")
public class RoomController {
    @Autowired
    private IRoomService service;

    @RequestMapping("findByItem")
    public IPage<RoomBean> findByItem(Integer pageNO, String roomStatus, String roomAddress, String roomType, String isLive){
       return service.findByItem(pageNO, roomStatus, roomAddress, roomType, isLive);
    }
    @RequestMapping("findBySex")
    public List<RoomBean> findBySex(String sex){
        return service.findBySex(sex);
    }
    @RequestMapping("delRoom")
    public String  delRoom(Integer roomId){
        boolean flag =service.delRoom(roomId);
        if (flag){
            return "ok";
        }else{
            return "no";
        }
    }
    @RequestMapping("findById")
    public RoomBean findById(Integer roomId){
        return service.findById(roomId);
    }
    @RequestMapping("addRoom")
    public String addRoom(RoomBean room){
        service.addRoom(room);
        return "ok";
    }
}
